

package com.ncu.controller.admin;

import com.baomidou.mybatisplus.extension.conditions.update.UpdateChainWrapper;
import com.ncu.domain.Ads;
import com.ncu.service.AdsService;
import com.ncu.utils.ResponseResult;
import com.ncu.vo.IsDisableVO;
import com.ncu.vo.QueryPageBean;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/adds"})
public class AdsController {
    @Autowired
    AdsService adsService;

    public AdsController() {
    }

    @PostMapping({"/getAdsPage"})
    public ResponseResult getSeatPage(@RequestBody QueryPageBean queryPageBean) {
        return ResponseResult.success("获取active分页成功", this.adsService.getSeatPage(queryPageBean));
    }

    @DeleteMapping({"/delete"})
    public ResponseResult delete(@RequestBody List<Long> list) {
        this.adsService.removeByIds(list);
        return ResponseResult.success("删除标签成功");
    }

    @PostMapping({"/saveOrUpdate"})
    public ResponseResult saveOrUpdateTag(@RequestBody Ads ads) {
        ads.setStatus(false);
        boolean flag = this.adsService.saveOrUpdate(ads);
        return flag ? ResponseResult.success("添加或更改成功") : ResponseResult.error("添加失败，要添加的轮播图已存在");
    }

    @PostMapping({"/typeIsDisable"})
    public ResponseResult bookDisable(@RequestBody IsDisableVO isDisableVO) {
     adsService.update().set("status",isDisableVO.getIsDisable()).eq("id",isDisableVO.getId()).update();
        return ResponseResult.success("修改成功");
    }
}
